package com.fkcai.hansoul.model.vo.user;

import com.fkcai.hansoul.model.entity.User;
import lombok.Data;

/**
 * 用户基本信息
 */
@Data
public class UserBasicVo {
	private Integer userId;
	private String phone;
	private String username;
	private String token;
	
	// 从 User 对象中负责必要字段
	public static UserBasicVo fromUser(User user) {
		return fromUser(user, null);
	}
	
	// 重载方法，支持设置 token
	public static UserBasicVo fromUser(User user, String token) {
		UserBasicVo userBasicVo = new UserBasicVo();
		userBasicVo.setUserId(user.getUserId());
		userBasicVo.setPhone(user.getPhone());
		userBasicVo.setUsername(user.getUsername());
		
		userBasicVo.setToken(token); // 设置 token
		
		return userBasicVo;
	}
}
